package com.msc.cili.service.blog.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.msc.cili.common.utils.BdUtil;
import com.msc.cili.repository.dao.blog.BlogMapper;
import com.msc.cili.repository.entity.blog.Blog;
import com.msc.cili.repository.to.blog.BlogInfoTo;
import com.msc.cili.service.blog.BlogService;
import com.msc.cili.service.blog.bo.BlogInfoBo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 服务实现类
 *
 * @author coder-msc
 * @date 2021-04-08
 */
@Service
public class BlogServiceImpl extends ServiceImpl<BlogMapper, Blog> implements BlogService {

    @Autowired
    BlogMapper blogMapper;

    /**
     * 通过分类名查找属于该分类的博客list
     *
     * @param categoryName 分类名
     * @return 博客list
     */
    @Override
    public List<BlogInfoBo> getBlogInfoListByCategoryName(String categoryName) {
        List<BlogInfoTo> blogByTypeName = blogMapper.getBlogByTypeName(categoryName);
        List<BlogInfoBo> blogInfoBos = BdUtil.bo2do4List(blogByTypeName, BlogInfoBo.class);
        return blogInfoBos;
    }

}
